package top.infopub.enums.cap;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//贷款类型枚举类
public enum LoanStyleEnum {
    PAY_INT_DET_TYPE1("1", "创新融资"),
    PAY_INT_DET_TYPE2("2", "资本市场"),
    PAY_INT_DET_TYPE3("3", "信托贷款"),
    PAY_INT_DET_TYPE4("4", "私募"),
    PAY_INT_DET_TYPE5("5", "资管"),
    PAY_INT_DET_TYPE6("6", "固定资产贷款"),
    PAY_INT_DET_TYPE7("7", "流动资金贷款"),
    PAY_INT_DET_TYPE8("8", "并购贷"),
    PAY_INT_DET_TYPE9("9", "融资租赁"),
    PAY_INT_DET_TYPE10("10", "保理"),
    PAY_INT_DET_TYPE11("11", "商业承兑汇票"),
    PAY_INT_DET_TYPE12("12", "保函"),
    PAY_INT_DET_TYPE13("13", "其他");

    private String code;

    private String name;

    LoanStyleEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static LoanStyleEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) return null;
        for (LoanStyleEnum pidte : LoanStyleEnum.values()) {
            if (StringUtils.equals(code, pidte.getCode())) {
                return pidte;
            }
        }
        return null;
    }

    public static List<Map<String, String>> asList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map;
        for (LoanStyleEnum pidte : LoanStyleEnum.values()) {
            map = new HashMap<>();
            map.put("code", pidte.getCode());
            map.put("name", pidte.getName());
            list.add(map);
        }
        return list;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
